package com.ssy.lingxi.platform.template.service.entity.adorn;

import com.ssy.lingxi.platform.template.service.handler.convert.JpaJsonToJsonObjectConverter;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import java.util.Map;

/**
 * 活动页 - DO
 * @author fhj
 * @date 2021/08/05
 * @version 2.0.0
 */
@Data
@Entity
@Table(schema = "public", name = "pt_activity_page", indexes = {
        @Index(name = "pt_activity_page_member_id_idx", columnList = "memberId"),
        @Index(name = "pt_activity_page_role_id_idx", columnList = "roleId"),
        @Index(name = "pt_activity_page_type_idx", columnList = "type")
})
public class ActivityPage {

    @Id
    @GeneratedValue(strategy= GenerationType.SEQUENCE, generator="activity_page_seq")
    @SequenceGenerator(sequenceName="pt_activity_page_seq", name="activity_page_seq", allocationSize = 1)
    @ApiModelProperty(value = "ID")
    private Long id;

    @Column(columnDefinition = "int8")
    @ApiModelProperty(value = "会员ID")
    private Long memberId;

    @Column(columnDefinition = "int8")
    @ApiModelProperty(value = "角色ID")
    private Long roleId;

    @Column(columnDefinition = "varchar(200)")
    @ApiModelProperty(value = "会员名称")
    private String memberName;

    @Column(columnDefinition = "int2")
    @ApiModelProperty(value = "类型: 1.平台 2.商家")
    private Integer type;

    @Column(columnDefinition = "varchar(64)")
    @ApiModelProperty(value = "活动页名称")
    private String name;

    @Column(columnDefinition = "int8")
    @ApiModelProperty(value = "开始时间")
    private Long startTime;

    @Column(columnDefinition = "int8")
    @ApiModelProperty(value = "结束时间")
    private Long endTime;

    @Column(columnDefinition = "int2")
    @ApiModelProperty(value = "适用环境: 1.WEB 2.H5 3.小程序 4.APP")
    private Integer environment;

    @Column(columnDefinition = "varchar(20)")
    @ApiModelProperty(value = "适用环境（冗余）")
    private String environmentName;

    @Column(columnDefinition = "int8")
    @ApiModelProperty(value = "活动模板ID")
    private Long templateId;

    @Column(columnDefinition = "varchar(20)")
    @ApiModelProperty(value = "活动模板名称")
    private String templateName;

    @Column(columnDefinition = "varchar(500)")
    @ApiModelProperty(value = "活动模板图片")
    private String templatePicUrl;

    @Column(columnDefinition = "int8")
    @ApiModelProperty(value = "商城ID")
    private Long shopId;

    @Column(columnDefinition = "varchar(20)")
    @ApiModelProperty(value = "商城名称")
    private String shopName;

    @Column(columnDefinition = "int2")
    @ApiModelProperty(value = "状态: 1.待上线 2.已上线 3.进行中 4.已下线 5.已结束")
    private Integer status = 1;

    @Column(columnDefinition = "varchar(20)")
    @ApiModelProperty(value = "状态（冗余）")
    private String statusName;

    @Convert(converter = JpaJsonToJsonObjectConverter.class)
    @Column(columnDefinition="jsonb")
    @ApiModelProperty(value = "装修内容")
    private Map<String, Object> adornContent;

    @Column(columnDefinition = "int8")
    @ApiModelProperty(value = "创建时间")
    private Long createTime = System.currentTimeMillis();

    @Column(columnDefinition = "int8")
    @ApiModelProperty(value = "开始时间的定时任务ID")
    private Long startTimeTaskId;

    @Column(columnDefinition = "int8")
    @ApiModelProperty(value = "结束时间的定时任务ID")
    private Long endTimeTaskId;
    /**
     * 商城子域名
     */
    @Transient
    private String url;
    /**
     * 是否为自营商城：0.否；1.是；
     */
    @Transient
    private Integer self;
}
